﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Student
{
    enum Gender { Undefined, Male, Female };

    class Student
    {
        static readonly int MIN_AGE = 7;
        static readonly int MAX_AGE = 18;
        static readonly int MIN_NAME_LENGTH = 10;
        static readonly int MAX_NAME_LENGTH = 50;
        static readonly string MALE_GENDER = "male";
        static readonly string FEMALE_GENDER = "female";
        static readonly int MIN_KLASS = 1;
        static readonly int MAX_KLASS = 11;

        private string name = null;
        private int age = default(int);
        private int klass = default(int);
        private Gender sex = Gender.Undefined;
        private string ssn = null;

        public string Name
        {
            get { return this.name; }
        }

        public int Age
        {
            get { return this.age; }
        }

        public int Klass
        {
            get { return this.klass; }
        }

        public Gender Sex
        {
            get { return this.sex; }
        }

        public Student(string name, string sex, int age, int klass, string ssn)
        {
            if (name.Length < MIN_NAME_LENGTH || name.Length > MAX_NAME_LENGTH)
            {
                throw new ArgumentException(String.Format("The name must be between {0} and {1} characters",
                    MIN_NAME_LENGTH, MAX_NAME_LENGTH));
            }
            else
            {
                this.name = name;
            }

            if (sex.Equals(MALE_GENDER) == true)
            {
                this.sex = Gender.Male;
            }
            else if (sex.Equals(FEMALE_GENDER) == true)
            {
                this.sex = Gender.Female;
            }
            else
            {
                throw new ArgumentException(String.Format("The possible human genders that are known are {0} and {1}",
                    MALE_GENDER, FEMALE_GENDER));
            }

            if (age < MIN_AGE || age > MAX_AGE)
            {
                throw new ArgumentException(String.Format("Student age must be between {0} and {1} years old",
                    MIN_AGE, MAX_AGE));
            }
            else
            {
                this.age = age;
            }

            if (klass < MIN_KLASS || klass > MAX_KLASS)
            {
                throw new ArgumentException(String.Format("Student klass must be between {0} and {1}", 
                    MIN_KLASS, MAX_KLASS));
            }
            else
            {
                this.klass = klass;
            }
        }

        public override string ToString()
        {
            return String.Format("{0} is {1} years old, {2} student from {3} class",
                this.name, this.age, this.sex, this.klass);
        }
    }
}
